package bosque.unc.gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Toolkit;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;

import bosque.unc.ayuda.LecturasAyuda;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.Locale;
import java.awt.Color;

public class AjusteLecturasGUI extends JFrame 
{

	private JPanel contentPane;
	private JTextField txtLecturaCupAzi;
	private JTextField txtLecturaPlataAlt;
	private JTextField txtLecturaPlataRad;
	private JTextField txtLecturaEspecX;
	private JTextField txtLecturaEspecY;
	private JTextField txtLecturaEspecPhi;
	private JTextField txtLecturaTempExt;
	private JTextField txtLecturaTempEsp;
	private JTextField txtFDCCupuAzi;
	private JTextField txtFDCPlataAlt;
	private JTextField txtFDCPlataRad;
	private JTextField txtFDCEspecX;
	private JTextField txtFDCEspecY;
	private JTextField txtFDCEspecPhi;
	private JTextField txtFDCTempExt;
	private JTextField txtFDCTempEsp;	
	private JButton btnCorregir1 ;
	private JButton btnCorregir2 ;
	private JButton btnCorregir3 ;
	private JButton btnCorregir6 ;
	private JButton btnCorregir7 ;
	private JButton btnCorregir8 ;
	private JButton btnCorregir4 ;
	private JButton btnCorregir5 ;
	private JButton btnLecturasActualizar;
	private JButton btnResetearFactores;
	private JButton btnAyuda;
	
	private JTextField textValVerTempEspejo;
	private JTextField textValVerTempExt;
	private JTextField textValVerEspecPhi;
	private JTextField textValVerEspecY;
	private JTextField textValVerEspecX;
	private JTextField textValVerPlatRadio;
	private JTextField textValVerPlatAlt;
	private JTextField textValVerCupAzimut;
	

	private static Scoba scoba;
	private LecturasAyuda lectruasAyuda;
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() 
		{
			public void run() 
			{
				
				try
				{
					System.out.println("Look and Fell: " + UIManager.getSystemLookAndFeelClassName());
					UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
				}
				catch (Exception ex)
				{
					System.out.println("Failed loading L&F: ");
					System.out.println(ex);
				}
				
				try {
					AjusteLecturasGUI frame = new AjusteLecturasGUI(scoba);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Constructor
	 * Create the frame.
	 */
	public AjusteLecturasGUI(Scoba sco) 
	{
		AjusteLecturasGUI.scoba = sco;
		inicialize();
	}
	public void inicialize()
	{
		
		Locale.setDefault(Locale.US);
		this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("resources/lecturas.png")));
		setTitle("Lecturas");	
		setResizable(false);
		setBounds(100, 100, 690, 458);
		getContentPane().setLayout(null);

		JLabel lblLectura = new JLabel("Lectura Actual");
		lblLectura.setFont(new Font("Tahoma", Font.PLAIN, 11));
		lblLectura.setBounds(163, 80, 69, 14);
		getContentPane().add(lblLectura);
		
		txtLecturaCupAzi = new JTextField();
		txtLecturaCupAzi.setHorizontalAlignment(SwingConstants.RIGHT);
		txtLecturaCupAzi.setEditable(false);
		txtLecturaCupAzi.setBounds(163, 105, 69, 20);
		getContentPane().add(txtLecturaCupAzi);
		txtLecturaCupAzi.setColumns(10);
		
		txtLecturaPlataAlt = new JTextField();
		txtLecturaPlataAlt.setHorizontalAlignment(SwingConstants.RIGHT);
		txtLecturaPlataAlt.setEditable(false);
		txtLecturaPlataAlt.setBounds(163, 136, 69, 20);
		getContentPane().add(txtLecturaPlataAlt);
		txtLecturaPlataAlt.setColumns(10);
		
		txtLecturaPlataRad = new JTextField();
		txtLecturaPlataRad.setHorizontalAlignment(SwingConstants.RIGHT);
		txtLecturaPlataRad.setEditable(false);
		txtLecturaPlataRad.setBounds(163, 167, 69, 20);
		getContentPane().add(txtLecturaPlataRad);
		txtLecturaPlataRad.setColumns(10);
		
		txtLecturaEspecX = new JTextField();
		txtLecturaEspecX.setHorizontalAlignment(SwingConstants.RIGHT);
		txtLecturaEspecX.setEditable(false);
		txtLecturaEspecX.setBounds(163, 263, 69, 20);
		getContentPane().add(txtLecturaEspecX);
		txtLecturaEspecX.setColumns(10);
		
		txtLecturaEspecY = new JTextField();
		txtLecturaEspecY.setHorizontalAlignment(SwingConstants.RIGHT);
		txtLecturaEspecY.setEditable(false);
		txtLecturaEspecY.setColumns(10);
		txtLecturaEspecY.setBounds(163, 294, 69, 20);
		getContentPane().add(txtLecturaEspecY);
		
		txtLecturaEspecPhi = new JTextField();
		txtLecturaEspecPhi.setHorizontalAlignment(SwingConstants.RIGHT);
		txtLecturaEspecPhi.setEditable(false);
		txtLecturaEspecPhi.setColumns(10);
		txtLecturaEspecPhi.setBounds(163, 325, 69, 20);
		getContentPane().add(txtLecturaEspecPhi);
		
		txtLecturaTempExt = new JTextField();
		txtLecturaTempExt.setHorizontalAlignment(SwingConstants.RIGHT);
		txtLecturaTempExt.setEditable(false);
		txtLecturaTempExt.setColumns(10);
		txtLecturaTempExt.setBounds(163, 198, 69, 20);
		getContentPane().add(txtLecturaTempExt);
		
		txtLecturaTempEsp = new JTextField();
		txtLecturaTempEsp.setHorizontalAlignment(SwingConstants.RIGHT);
		txtLecturaTempEsp.setEditable(false);
		txtLecturaTempEsp.setColumns(10);
		txtLecturaTempEsp.setBounds(163, 229, 69, 20);
		getContentPane().add(txtLecturaTempEsp);
		
		JLabel lblCupulaAzimut = new JLabel("Cupula Azimut  :");
		lblCupulaAzimut.setHorizontalAlignment(SwingConstants.RIGHT);
		lblCupulaAzimut.setBounds(22, 108, 119, 14);
		getContentPane().add(lblCupulaAzimut);
		
		JLabel lblAlturaPlataforma = new JLabel("Altura Plataforma :");
		lblAlturaPlataforma.setHorizontalAlignment(SwingConstants.RIGHT);
		lblAlturaPlataforma.setBounds(22, 139, 119, 14);
		getContentPane().add(lblAlturaPlataforma);
		
		JLabel lblRadioPlataforma = new JLabel("Radio Plataforma :");
		lblRadioPlataforma.setHorizontalAlignment(SwingConstants.RIGHT);
		lblRadioPlataforma.setBounds(22, 170, 119, 14);
		getContentPane().add(lblRadioPlataforma);
		
		JLabel lblEspectrgrafoX = new JLabel("Espectr\u00F3grafo X :");
		lblEspectrgrafoX.setHorizontalAlignment(SwingConstants.RIGHT);
		lblEspectrgrafoX.setBounds(22, 269, 119, 14);
		getContentPane().add(lblEspectrgrafoX);
		
		JLabel lblEspectrgrafoY = new JLabel("Espectr\u00F3grafo Y :");
		lblEspectrgrafoY.setHorizontalAlignment(SwingConstants.RIGHT);
		lblEspectrgrafoY.setBounds(22, 297, 119, 14);
		getContentPane().add(lblEspectrgrafoY);
		
		JLabel lblEspectrgrafoPhi = new JLabel("Espectr\u00F3grafo Phi :");
		lblEspectrgrafoPhi.setHorizontalAlignment(SwingConstants.RIGHT);
		lblEspectrgrafoPhi.setBounds(22, 328, 119, 14);
		getContentPane().add(lblEspectrgrafoPhi);
		
		JLabel lblTemperaturaExterior = new JLabel("Temperatura Exterior :");
		lblTemperaturaExterior.setHorizontalAlignment(SwingConstants.RIGHT);
		lblTemperaturaExterior.setBounds(0, 204, 141, 14);
		getContentPane().add(lblTemperaturaExterior);
		
		JLabel lblTemperaturaEspejo = new JLabel("Temperatura Espejo :");
		lblTemperaturaEspejo.setHorizontalAlignment(SwingConstants.RIGHT);
		lblTemperaturaEspejo.setBounds(22, 232, 119, 14);
		getContentPane().add(lblTemperaturaEspejo);
		
		JLabel lblFactorDeCorreccin = new JLabel("Factor de Correcci\u00F3n");
		lblFactorDeCorreccin.setBounds(478, 80, 131, 14);
		getContentPane().add(lblFactorDeCorreccin);
		
		txtFDCCupuAzi = new JTextField();
		txtFDCCupuAzi.setEditable(false);
		txtFDCCupuAzi.setColumns(10);
		txtFDCCupuAzi.setBounds(499, 103, 69, 20);
		getContentPane().add(txtFDCCupuAzi);
		
		txtFDCPlataAlt = new JTextField();
		txtFDCPlataAlt.setEditable(false);
		txtFDCPlataAlt.setColumns(10);
		txtFDCPlataAlt.setBounds(499, 134, 69, 20);
		getContentPane().add(txtFDCPlataAlt);
		
		txtFDCPlataRad = new JTextField();
		txtFDCPlataRad.setEditable(false);
		txtFDCPlataRad.setColumns(10);
		txtFDCPlataRad.setBounds(499, 165, 69, 20);
		getContentPane().add(txtFDCPlataRad);
		
		txtFDCEspecX = new JTextField();
		txtFDCEspecX.setEditable(false);
		txtFDCEspecX.setColumns(10);
		txtFDCEspecX.setBounds(499, 261, 69, 20);
		getContentPane().add(txtFDCEspecX);
		
		txtFDCEspecY = new JTextField();
		txtFDCEspecY.setEditable(false);
		txtFDCEspecY.setColumns(10);
		txtFDCEspecY.setBounds(499, 292, 69, 20);
		getContentPane().add(txtFDCEspecY);
		
		txtFDCEspecPhi = new JTextField();
		txtFDCEspecPhi.setEditable(false);
		txtFDCEspecPhi.setColumns(10);
		txtFDCEspecPhi.setBounds(499, 323, 69, 20);
		getContentPane().add(txtFDCEspecPhi);
		
		txtFDCTempExt = new JTextField();
		txtFDCTempExt.setEditable(false);
		txtFDCTempExt.setColumns(10);
		txtFDCTempExt.setBounds(499, 196, 69, 20);
		getContentPane().add(txtFDCTempExt);
		
		txtFDCTempEsp = new JTextField();
		txtFDCTempEsp.setEditable(false);
		txtFDCTempEsp.setColumns(10);
		txtFDCTempEsp.setBounds(499, 227, 69, 20);
		getContentPane().add(txtFDCTempEsp);
		
		btnCorregir1 = new JButton("Corregir");
		btnCorregir1.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent arg0) 
			{
													
				if(textValVerCupAzimut.getText().trim().length()==0)
				 {
				    JOptionPane.showMessageDialog(btnCorregir1, "Debe ingresar un numero .");   					
				 }
				else 
				{
					Double factorNuevo = 0.0;					
					Integer lecturaVer = 0;  // cupula azimut es el unico caso que es Integer
					Double factorViejo = scoba.getLecturas().getCupulaAzFactorCorrec();
					Integer lecturaSinCorreccion = scoba.getCupula().getAzimut() - factorViejo.intValue();
					lecturaVer = Integer.parseInt(textValVerCupAzimut.getText());
					factorNuevo = lecturaSinCorreccion.doubleValue() - lecturaVer.doubleValue();
					factorNuevo =  factorNuevo * (-1.0); // si es positivo lo hace negativo
					scoba.getLecturas().setCupulaAzFactorCorrec(factorNuevo);
					txtFDCCupuAzi.setText(String.format("%.2f",factorNuevo));
					
				}
				
			}
		});
		btnCorregir1.setBounds(371, 102, 92, 23);
		getContentPane().add(btnCorregir1);
		
		 btnCorregir2= new JButton("Corregir");
		btnCorregir2.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				
				if(textValVerPlatAlt.getText().trim().length()==0)
				 {
				    JOptionPane.showMessageDialog(btnCorregir1, "Debe ingresar un numero");   					
				 }
				else 
				{
					Double factorNuevo = 0.0;					
					Double lecturaVer  = 0.0;  
					Double factorViejo = scoba.getLecturas().getPlatafAltFactorCorrec();
					Double lecturaSinCorreccion = scoba.getPlataforma().getAltura() - factorViejo;
					lecturaVer = Double.parseDouble(textValVerPlatAlt.getText());
					factorNuevo = lecturaSinCorreccion.doubleValue() - lecturaVer.doubleValue();
					factorNuevo =  factorNuevo * (-1.0); // si es positivo lo hace negativo
					scoba.getLecturas().setPlatafAltFactorCorrec(factorNuevo);
					txtFDCPlataAlt.setText(String.format("%.2f",factorNuevo));				
					
				}				
			}
		});
		btnCorregir2.setBounds(371, 133, 92, 23);
		getContentPane().add(btnCorregir2);
		
		 btnCorregir3 = new JButton("Corregir");
		btnCorregir3.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				
				if(textValVerPlatRadio.getText().trim().length()==0)
				 {
				    JOptionPane.showMessageDialog(btnCorregir1, "Debe ingresar un numero");   					
				 }
				else 
				{
					
					Double factorNuevo = 0.0;					
					Double lecturaVer  = 0.0;  
					Double factorViejo = scoba.getLecturas().getPlatafRadioFactorCorrec();
					Double lecturaSinCorreccion = scoba.getPlataforma().getRadio() - factorViejo;
					lecturaVer = Double.parseDouble(textValVerPlatRadio.getText());
					factorNuevo = lecturaSinCorreccion.doubleValue() - lecturaVer.doubleValue();
					factorNuevo =  factorNuevo * (-1.0); // si es positivo lo hace negativo
					scoba.getLecturas().setPlatafRadioFactorCorrec(factorNuevo);
					txtFDCPlataRad.setText(String.format("%.2f",factorNuevo));
	
				}
				
			}
		});
		btnCorregir3.setBounds(371, 164, 92, 23);
		getContentPane().add(btnCorregir3);
		
		 btnCorregir6 = new JButton("Corregir");
		btnCorregir6.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				
				if(textValVerEspecX.getText().trim().length()==0)
				 {
				    JOptionPane.showMessageDialog(btnCorregir1, "Debe ingresar un numero");   					
				 }
				else 
				{
					Double factorNuevo = 0.0;					
					Double lecturaVer  = 0.0;  
					Double factorViejo = scoba.getLecturas().getEspXFactorCorrec();
					Double lecturaSinCorreccion = scoba.getEspectrografo().getEjeX() - factorViejo;
					lecturaVer = Double.parseDouble(textValVerEspecX.getText());
					factorNuevo = lecturaSinCorreccion.doubleValue() - lecturaVer.doubleValue();
					factorNuevo =  factorNuevo * (-1.0); // si es positivo lo hace negativo
					scoba.getLecturas().setEspXFactorCorrec(factorNuevo);
					txtFDCEspecX.setText(String.format("%.2f",factorNuevo));

				}	
				
			}
		});
		btnCorregir6.setBounds(371, 260, 92, 23);
		getContentPane().add(btnCorregir6);
		
		btnCorregir7 = new JButton("Corregir");
		btnCorregir7.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				
				if(textValVerEspecY.getText().trim().length()==0)
				 {
				    JOptionPane.showMessageDialog(btnCorregir1, "Debe ingresar un numero");   					
				 }
				else 
				{
					
					Double factorNuevo = 0.0;					
					Double lecturaVer  = 0.0;  
					Double factorViejo = scoba.getLecturas().getEspYFactorCorrec();
					Double lecturaSinCorreccion = scoba.getEspectrografo().getEjeY() - factorViejo;
					lecturaVer = Double.parseDouble(textValVerEspecY.getText());
					factorNuevo = lecturaSinCorreccion.doubleValue() - lecturaVer.doubleValue();
					factorNuevo =  factorNuevo * (-1.0); // si es positivo lo hace negativo
					scoba.getLecturas().setEspYFactorCorrec(factorNuevo);
					txtFDCEspecY.setText(String.format("%.2f",factorNuevo));
										
				}
				
				
			}
		});
		 btnCorregir7.setBounds(371, 291, 92, 23);
		getContentPane().add( btnCorregir7);
		
		btnCorregir8 = new JButton("Corregir");
		btnCorregir8.setEnabled(true);
		btnCorregir8.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				
				if(textValVerEspecPhi.getText().trim().length()==0)
				 {
				    JOptionPane.showMessageDialog(btnCorregir1, "Debe ingresar un numero");   					
				 }
				else 
				{
				
					Double factorNuevo = 0.0;					
					Double lecturaVer  = 0.0;  
					Double factorViejo = scoba.getLecturas().getEspFiFactorCorrec();
					Double lecturaSinCorreccion = scoba.getEspectrografo().getPhi() - factorViejo;
					lecturaVer = Double.parseDouble(textValVerEspecPhi.getText());
					factorNuevo = lecturaSinCorreccion.doubleValue() - lecturaVer.doubleValue();
					factorNuevo =  factorNuevo * (-1.0); // si es positivo lo hace negativo
					scoba.getLecturas().setEspFiFactorCorrec(factorNuevo);
					txtFDCEspecPhi.setText(String.format("%.2f",factorNuevo));

				}
				
			}
		});
		btnCorregir8.setBounds(371, 322, 92, 23);
		getContentPane().add(btnCorregir8);
		
		btnCorregir4 = new JButton("Corregir");
		btnCorregir4.setEnabled(true);
		btnCorregir4.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				
				if(textValVerTempExt.getText().trim().length()==0)
				 {
				    JOptionPane.showMessageDialog(btnCorregir1, "Debe ingresar un numero");   					
				 }
				else 
				{
					
					Double factorNuevo = 0.0;					
					Double lecturaVer  = 0.0;  
					Double factorViejo = scoba.getLecturas().getTempExtFactorCorrec();
					Double lecturaSinCorreccion = scoba.getTelescopio().getTempExterior() - factorViejo;
					lecturaVer = Double.parseDouble(textValVerTempExt.getText());
					factorNuevo = lecturaSinCorreccion.doubleValue() - lecturaVer.doubleValue();
					factorNuevo =  factorNuevo * (-1.0); // si es positivo lo hace negativo
					scoba.getLecturas().setTempExtFactorCorrec(factorNuevo);
					txtFDCTempExt.setText(String.format("%.2f",factorNuevo));
					
				}
				
			}
		});
		btnCorregir4.setBounds(371, 195, 92, 23);
		getContentPane().add(btnCorregir4);
		
		btnCorregir5 = new JButton("Corregir");
		btnCorregir5.setEnabled(true);
		btnCorregir5.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				
				if(textValVerTempEspejo.getText().trim().length()==0)
				 {
				    JOptionPane.showMessageDialog(btnCorregir1, "Debe ingresar un numero");   					
				 }
				else 
				{
					Double factorNuevo = 0.0;					
					Double lecturaVer  = 0.0;  
					Double factorViejo = scoba.getLecturas().getTempEspejoFactorCorrec();
					Double lecturaSinCorreccion = scoba.getTelescopio().getTempEspejo() - factorViejo;
					lecturaVer = Double.parseDouble(textValVerTempEspejo.getText());
					factorNuevo = lecturaSinCorreccion.doubleValue() - lecturaVer.doubleValue();
					factorNuevo =  factorNuevo * (-1.0); // si es positivo lo hace negativo
					scoba.getLecturas().setTempEspejoFactorCorrec(factorNuevo);
					txtFDCTempEsp.setText(String.format("%.2f",factorNuevo));					
				}				
			}
		});
		btnCorregir5.setBounds(371, 226, 92, 23);
		getContentPane().add(btnCorregir5);
		
		JLabel lblCorreccionDeLecturas = new JLabel("CORRECCION DE LECTURAS");
		lblCorreccionDeLecturas.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lblCorreccionDeLecturas.setBounds(168, 23, 250, 23);
		getContentPane().add(lblCorreccionDeLecturas);
		

		btnLecturasActualizar = new JButton("Mostrar Lecturas");
		btnLecturasActualizar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				txtLecturaCupAzi.setText(scoba.getCupula().getAzimut().toString());
				txtFDCCupuAzi.setText(String.format("%.2f", scoba.getLecturas().getCupulaAzFactorCorrec()));
				
				txtLecturaPlataAlt.setText(String.format("%.2f",scoba.getPlataforma().getAltura()));
				txtFDCPlataAlt.setText(String.format("%.2f", scoba.getLecturas().getPlatafAltFactorCorrec()));
				
				txtLecturaPlataRad.setText(String.format("%.2f",scoba.getPlataforma().getRadio()));
				txtFDCPlataRad.setText(String.format("%.2f", scoba.getLecturas().getPlatafRadioFactorCorrec()));		
				
				txtLecturaTempEsp.setText(String.format("%.2f",scoba.getTelescopio().getTempEspejo()));
				txtFDCTempEsp.setText(String.format("%.2f",scoba.getLecturas().getTempEspejoFactorCorrec()));
				
				txtLecturaTempExt.setText(String.format("%.2f",scoba.getTelescopio().getTempExterior()));
				txtFDCTempExt.setText(String.format("%.2f",scoba.getLecturas().getTempExtFactorCorrec()));
				
				txtLecturaEspecX.setText(String.format("%.2f",scoba.getEspectrografo().getEjeX()));
				txtFDCEspecX.setText(String.format("%.2f", scoba.getLecturas().getEspXFactorCorrec()));
				
				
				txtLecturaEspecY.setText(String.format("%.2f",scoba.getEspectrografo().getEjeY()));
				txtFDCEspecY.setText(String.format("%.2f", scoba.getLecturas().getEspYFactorCorrec()));
				
				txtLecturaEspecPhi.setText(String.format("%.2f",scoba.getEspectrografo().getPhi()));
				txtFDCEspecPhi.setText(String.format("%.2f", scoba.getLecturas().getEspFiFactorCorrec()));
				
			
			}
		});
		btnLecturasActualizar.setBounds(86, 377, 124, 23);
		getContentPane().add(btnLecturasActualizar);
		
		btnResetearFactores = new JButton("Resetear Factores");
		btnResetearFactores.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent arg0) 
			{
				
				scoba.getLecturas().setCupulaAzFactorCorrec(0.0);
				txtFDCCupuAzi.setText(String.format("%.2f", scoba.getLecturas().getCupulaAzFactorCorrec()));
				
				scoba.getLecturas().setPlatafAltFactorCorrec(0.0);
				txtFDCPlataAlt.setText(String.format("%.2f", scoba.getLecturas().getPlatafAltFactorCorrec()));
				
				scoba.getLecturas().setPlatafRadioFactorCorrec(0.0);
				txtFDCPlataRad.setText(String.format("%.2f", scoba.getLecturas().getPlatafRadioFactorCorrec()));
				
				scoba.getLecturas().setTempExtFactorCorrec(0.0);
				txtFDCTempExt.setText(String.format("%.2f",scoba.getLecturas().getTempExtFactorCorrec()));
				
				scoba.getLecturas().setTempEspejoFactorCorrec(0.0);
				txtFDCTempEsp.setText(String.format("%.2f",scoba.getLecturas().getTempEspejoFactorCorrec()));
				
				scoba.getLecturas().setEspXFactorCorrec(0.0);	
				txtFDCEspecX.setText(String.format("%.2f", scoba.getLecturas().getEspXFactorCorrec()));
				
				scoba.getLecturas().setEspYFactorCorrec(0.0);
				txtFDCEspecY.setText(String.format("%.2f", scoba.getLecturas().getEspYFactorCorrec()));
				
				scoba.getLecturas().setEspFiFactorCorrec(0.0);
				txtFDCEspecPhi.setText(String.format("%.2f", scoba.getLecturas().getEspFiFactorCorrec()));
		
			}
		});
		btnResetearFactores.setBounds(220, 377, 131, 23);
		getContentPane().add(btnResetearFactores);
		
		textValVerTempEspejo = new JTextField();
		textValVerTempEspejo.setColumns(10);
		textValVerTempEspejo.setBounds(270, 229, 69, 20);
		getContentPane().add(textValVerTempEspejo);
		
		textValVerTempExt = new JTextField();
		textValVerTempExt.setColumns(10);
		textValVerTempExt.setBounds(270, 198, 69, 20);
		getContentPane().add(textValVerTempExt);
		
		textValVerEspecPhi = new JTextField();
		textValVerEspecPhi.setColumns(10);
		textValVerEspecPhi.setBounds(270, 325, 69, 20);
		getContentPane().add(textValVerEspecPhi);
		
		textValVerEspecY = new JTextField();
		textValVerEspecY.setColumns(10);
		textValVerEspecY.setBounds(270, 294, 69, 20);
		getContentPane().add(textValVerEspecY);
		
		textValVerEspecX = new JTextField();
		textValVerEspecX.setColumns(10);
		textValVerEspecX.setBounds(270, 263, 69, 20);
		getContentPane().add(textValVerEspecX);
		
		textValVerPlatRadio = new JTextField();
		textValVerPlatRadio.setColumns(10);
		textValVerPlatRadio.setBounds(270, 167, 69, 20);
		getContentPane().add(textValVerPlatRadio);
		
		textValVerPlatAlt = new JTextField();
		textValVerPlatAlt.setColumns(10);
		textValVerPlatAlt.setBounds(270, 136, 69, 20);
		getContentPane().add(textValVerPlatAlt);
		
		textValVerCupAzimut = new JTextField();
		textValVerCupAzimut.setColumns(10);
		textValVerCupAzimut.setBounds(270, 105, 69, 20);
		getContentPane().add(textValVerCupAzimut);
		
		JLabel lblValorVerdadero = new JLabel("Valor Verdadero");
		lblValorVerdadero.setFont(new Font("Tahoma", Font.PLAIN, 11));
		lblValorVerdadero.setBounds(265, 80, 85, 14);
		getContentPane().add(lblValorVerdadero);
		
		JButton btnGuardarConf = new JButton("Guardar Valores");
		btnGuardarConf.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				scoba.guardarConfiguracion();
			}
		});
		btnGuardarConf.setBounds(374, 377, 131, 23);
		getContentPane().add(btnGuardarConf);
		
		JButton btnResetFacCupAzi = new JButton("reset");
		btnResetFacCupAzi.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent arg0) 
			{
				
				scoba.getLecturas().setCupulaAzFactorCorrec(0.0);
				txtFDCCupuAzi.setText(String.format("%.2f", scoba.getLecturas().getCupulaAzFactorCorrec()));
			}
		});
		btnResetFacCupAzi.setBounds(592, 104, 62, 23);
		getContentPane().add(btnResetFacCupAzi);
		
		JButton btnResetFacPlataAlt = new JButton("reset");
		btnResetFacPlataAlt.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{			
				scoba.getLecturas().setPlatafAltFactorCorrec(0.0);
				txtFDCPlataAlt.setText(String.format("%.2f", scoba.getLecturas().getPlatafAltFactorCorrec()));
			}
		});
		btnResetFacPlataAlt.setBounds(592, 135, 62, 23);
		getContentPane().add(btnResetFacPlataAlt);
		
		JButton btnResetFacPlataRadio = new JButton("reset");
		btnResetFacPlataRadio.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				scoba.getLecturas().setPlatafRadioFactorCorrec(0.0);
				txtFDCPlataRad.setText(String.format("%.2f", scoba.getLecturas().getPlatafRadioFactorCorrec()));
			}
		});
		btnResetFacPlataRadio.setBounds(592, 166, 62, 23);
		getContentPane().add(btnResetFacPlataRadio);
		
		JButton btnResetFacTempExt = new JButton("reset");
		btnResetFacTempExt.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{		
				scoba.getLecturas().setTempExtFactorCorrec(0.0);
				txtFDCTempExt.setText(String.format("%.2f",scoba.getLecturas().getTempExtFactorCorrec()));
			}
		});
		btnResetFacTempExt.setBounds(592, 197, 62, 23);
		getContentPane().add(btnResetFacTempExt);
		
		JButton btnResetFacTempEsp = new JButton("reset");
		btnResetFacTempEsp.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				scoba.getLecturas().setTempEspejoFactorCorrec(0.0);
				txtFDCTempEsp.setText(String.format("%.2f",scoba.getLecturas().getTempEspejoFactorCorrec()));
			}
		});
		btnResetFacTempEsp.setBounds(592, 228, 62, 23);
		getContentPane().add(btnResetFacTempEsp);
		
		JButton btnResetFacEspX = new JButton("reset");
		btnResetFacEspX.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e)
			{
				scoba.getLecturas().setEspXFactorCorrec(0.0);	
				txtFDCEspecX.setText(String.format("%.2f", scoba.getLecturas().getEspXFactorCorrec()));
			}
		});
		btnResetFacEspX.setBounds(592, 262, 62, 23);
		getContentPane().add(btnResetFacEspX);
		
		JButton btnResetFacEspY = new JButton("reset");
		btnResetFacEspY.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{			
				scoba.getLecturas().setEspYFactorCorrec(0.0);
				txtFDCEspecY.setText(String.format("%.2f", scoba.getLecturas().getEspYFactorCorrec()));
			}
		});
		btnResetFacEspY.setBounds(592, 293, 62, 23);
		getContentPane().add(btnResetFacEspY);
		
		JButton btnResetFacEspPhi = new JButton("reset");
		btnResetFacEspPhi.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				scoba.getLecturas().setEspFiFactorCorrec(0.0);
				txtFDCEspecPhi.setText(String.format("%.2f", scoba.getLecturas().getEspFiFactorCorrec()));
			}
		});
		btnResetFacEspPhi.setBounds(592, 324, 62, 23);
		getContentPane().add(btnResetFacEspPhi);

		/*Validacion de los textFiel para que solo ingresen numero*/
		soloNumeros(textValVerTempEspejo);
		soloNumeros(textValVerTempExt);
		soloNumeros(textValVerEspecPhi);
		soloNumeros(textValVerEspecY);
		soloNumeros(textValVerEspecX);
		soloNumeros(textValVerPlatRadio);
		soloNumeros(textValVerPlatAlt);
		soloNumeros(textValVerCupAzimut);
		
		btnAyuda = new JButton("?");
		btnAyuda.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				
				try
				{
					if(!lectruasAyuda.isVisible())
						{						
						lectruasAyuda.setVisible(true);
						}
					else{
						lectruasAyuda.requestFocus();
						lectruasAyuda.setExtendedState(JFrame.NORMAL);
						}
				}
				catch(Exception e1)
				{
					lectruasAyuda = new LecturasAyuda();				
					lectruasAyuda.setVisible(true);
				}
				
				
			}
		});
		btnAyuda.setForeground(Color.BLUE);
		btnAyuda.setBackground(Color.BLUE);
		btnAyuda.setBounds(625, 25, 37, 23);
		getContentPane().add(btnAyuda);
		
		
	}

	
	/**
	 * @param a 
	 * Metodo para validar los JTextField solo permiten numeros
	 */
	public void soloNumeros(JTextField a)
	{
		
		a.addKeyListener(new KeyAdapter()
		{		
			public void keyTyped(KeyEvent e) 
			{				
				char c = e.getKeyChar();
				if(Character.isLetter(c))
				{					
					getToolkit().beep();
					e.consume(); // que no te permita ingresar letras
				}
			}	
		});
	}

	
	/*SETTERS Y GUETTERS*/
	
	public JTextField getTxtLecturaCupAzi() 
	{
		return txtLecturaCupAzi;
	}

	public void setTxtLecturaCupAzi(JTextField txtLecturaCupAzi) 
	{
		this.txtLecturaCupAzi = txtLecturaCupAzi;
	}

	public JTextField getTxtLecturaPlataAlt() 
	{
		return txtLecturaPlataAlt;
	}

	public void setTxtLecturaPlataAlt(JTextField txtLecturaPlataAlt) 
	{
		this.txtLecturaPlataAlt = txtLecturaPlataAlt;
	}

	public JTextField getTxtLecturaPlataRad() 
	{
		return txtLecturaPlataRad;
	}

	public void setTxtLecturaPlataRad(JTextField txtLecturaPlataRad) 
	{
		this.txtLecturaPlataRad = txtLecturaPlataRad;
	}

	public JTextField getTxtLecturaEspecX() 
	{
		return txtLecturaEspecX;
	}

	public void setTxtLecturaEspecX(JTextField txtLecturaEspecX) 
	{
		this.txtLecturaEspecX = txtLecturaEspecX;
	}

	public JTextField getTxtLecturaEspecY() 
	{
		return txtLecturaEspecY;
	}

	public void setTxtLecturaEspecY(JTextField txtLecturaEspecY)
	{
		this.txtLecturaEspecY = txtLecturaEspecY;
	}

	public JTextField getTxtLecturaEspecPhi() 
	{
		return txtLecturaEspecPhi;
	}

	public void setTxtLecturaEspecPhi(JTextField txtLecturaEspecPhi)
	{
		this.txtLecturaEspecPhi = txtLecturaEspecPhi;
	}

	public JTextField getTxtLecturaTempExt() 
	{
		return txtLecturaTempExt;
	}

	public void setTxtLecturaTempExt(JTextField txtLecturaTempExt)
	{
		this.txtLecturaTempExt = txtLecturaTempExt;
	}

	public JTextField getTxtLecturaTempEsp() 
	{
		return txtLecturaTempEsp;
	}

	public void setTxtLecturaTempEsp(JTextField txtLecturaTempEsp) 
	{
		this.txtLecturaTempEsp = txtLecturaTempEsp;
	}

	public JTextField getTxtFDCCupuAzi()
	{
		return txtFDCCupuAzi;
	}

	public void setTxtFDCCupuAzi(JTextField txtFDCCupuAzi) 
	{
		this.txtFDCCupuAzi = txtFDCCupuAzi;
	}

	public JTextField getTxtFDCPlataAlt()
	{
		return txtFDCPlataAlt;
	}

	public void setTxtFDCPlataAlt(JTextField txtFDCPlataAlt) 
	{
		this.txtFDCPlataAlt = txtFDCPlataAlt;
	}

	public JTextField getTxtFDCPlataRad()
	{
		return txtFDCPlataRad;
	}

	public void setTxtFDCPlataRad(JTextField txtFDCPlataRad) 
	{
		this.txtFDCPlataRad = txtFDCPlataRad;
	}

	public JTextField getTxtFDCEspecX()
	{
		return txtFDCEspecX;
	}

	public void setTxtFDCEspecX(JTextField txtFDCEspecX)
	{
		this.txtFDCEspecX = txtFDCEspecX;
	}

	public JTextField getTxtFDCEspecY() 
	{
		return txtFDCEspecY;
	}

	public void setTxtFDCEspecY(JTextField txtFDCEspecY) 
	{
		this.txtFDCEspecY = txtFDCEspecY;
	}

	public JTextField getTxtFDCEspecPhi()
	{
		return txtFDCEspecPhi;
	}

	public void setTxtFDCEspecPhi(JTextField txtFDCEspecPhi) 
	{
		this.txtFDCEspecPhi = txtFDCEspecPhi;
	}

	public JTextField getTxtFDCTempExt()
	{
		return txtFDCTempExt;
	}

	public void setTxtFDCTempExt(JTextField txtFDCTempExt) 
	{
		this.txtFDCTempExt = txtFDCTempExt;
	}

	public JTextField getTxtFDCTempEsp() 
	{
		return txtFDCTempEsp;
	}

	public void setTxtFDCTempEsp(JTextField txtFDCTempEsp) 
	{
		this.txtFDCTempEsp = txtFDCTempEsp;
	}
	public JTextField getTextValVerEspecY() 
	{
		return textValVerEspecY;
	}
	public JTextField getTextValVerCupAzimut() 
	{
		return textValVerCupAzimut;
	}
	public JTextField getTextValVerPlatAlt() 
	{
		return textValVerPlatAlt;
	}
	public JTextField getTextValVerTempEspejo() 
	{
		return textValVerTempEspejo;
	}
	public JTextField getTextValVerPlatRadio()
	{
		return textValVerPlatRadio;
	}
	public JTextField getTextValVerEspecPhi()
	{
		return textValVerEspecPhi;
	}
	public JTextField getTextValVerTempExt()
	{
		return textValVerTempExt;
	}
	public JTextField getTextValVerEspecX()
	{
		return textValVerEspecX;
	}
}
